{% extends "../layout.html" %}

{% block subtitle %}推文{% end %}
{% block style %}
  {% include "../includes/tweet_editor.html" %}
{% end %}
{% block script %}
<script type="text/javascript" src="{{ static_url('js/timeline.js') }}"></script>
<script type="text/javascript" src="{{ static_url('js/tweet.js') }}"></script>
{% end %}
{% block body %}
<ul class="item-list bgw">
  <li id="tweet-{{ tweet.id }}" data-id="{{ tweet.id }}" class="item clearfix">
    <a class="avatar fl" href="{{ tweet.author.url }}">
      <img class="avatar" src="{{ tweet.author.get_avatar(size=48) }}">
    </a>
    <div class="item-content">
      <div class="author-info">
        <a class="name" data-name="{{ tweet.author.name }}" href="{{ tweet.author.url }}">{{ escape(tweet.author.nickname) }}</a>
        <a class="time" href="{{ tweet.url }}">{{ tweet.created }}</a>
      </div>
      <div class="content tweet-content">
        {{ tweet.content }}
      </div>
      {% if tweet.has_img %}
      {% set images = tweet.images %}
      <div class="tweet-img-area close">
        {% if len(images) > 1 %}
        <div class="thumbs pr">
          <ul class="clr">
            {% for img in images %}
            <li>
              <img data-id="{{ img.id }}" src="{{ img.path }}">
            </li>
            {% end %}
          </ul>
        </div>
        {% end %}
        <span class="dib pr tweet-img-content">
          {% for i, img in enumerate(images) %}
          <span class="img-cover img-cover-{{ i+1 }}{% if i > 2 %} dn{% end %}">
            <img data-width="{{ img.width }}" data-height="{{ img.height }}" data-id="{{ img.id }}" src="{{ img.path }}">
              {% if i == 0 and len(images) > 1 %}
              <div class="label">{{ len(images) }}张图片</div>
              {% end %}
            </span>
          {% end %}
        </span>
      </div>
      {% end %}
      <div class="meta">
        {% if current_user %}
        <ul class="vote clearfix hidden">
          {% if current_user.is_upped(tweet=tweet) %}
          <li class="up pressed">
            <a title="取消赞同" href="{{ tweet.url }}?action=up"><i class="icon-thumbs-up"></i> 已赞同({{ tweet.up_count }})</a>
          </li>
          {% else %}
          <li class="up">
            <a title="赞同" href="{{ tweet.url }}?action=up"><i class="icon-thumbs-up"></i> 赞同({{ tweet.up_count }})</a>
          </li>
          {% end %}
          {% if current_user.is_downed(tweet=tweet) %}
          <li class="down pressed">
            <a title="取消反对" href="{{ tweet.url }}?action=down"><i class="icon-thumbs-down"></i> 已反对({{ tweet.down_count }})</a>
          </li>
          {% else %}
          <li class="down">
            <a title="反对" href="{{ tweet.url }}?action=down"><i class="icon-thumbs-down"></i> 反对({{ tweet.down_count }})</a>
          </li>
          {% end %}
          {% if current_user.is_collected(tweet=tweet) %}
          <li class="collect pressed">
            <a title="取消收藏" href="{{ tweet.url }}?action=collect"><i class="icon-bookmark"></i> 已收藏</a>
          </li>
          {% else %}
          <li class="collect">
            <a title="收藏" href="{{ tweet.url }}?action=collect"><i class="icon-bookmark"></i> 收藏</a>
          </li>
          {% end %}
          {% if current_user == tweet.author or current_user.is_admin %}
          <li class="remove">
            <a title="删除" href="{{ tweet.url }}"><i class="icon-trash"></i> 删除</a>
          </li>
          {% end %}
          {% if current_user != tweet.author %}
            {% if current_user.is_thanked(tweet=tweet) %}
            <li class="thank pressed">
              <a href="{{ tweet.url }}?action=thank"><i class="icon-heart"></i> 已感谢</a>
            </li>
            {% else %}
            <li class="thank">
              <a title="感谢" href="{{ tweet.url }}?action=thank"><i class="icon-heart"></i> 感谢</a>
            </li>
            {% end %}
            <li class="more">
              <a title="更多" href="#;"><i class="icon-ellipsis-horizontal"></i></a>
              <ul class="menu-list">
                {% if current_user.is_reported(tweet=tweet) %}
                <li class="collect pressed">
                  <a title="取消举报" href="{{ tweet.url }}?action=report"><i class="icon-flag"></i> 已举报</a>
                </li>
                {% else %}
                <li class="collect">
                  <a title="举报" href="{{ tweet.url }}?action=report"><i class="icon-flag"></i> 举报</a>
                </li>
                {% end %}
              </ul>
            </li>
          {% end %}
        </ul>
        <ul class="action clearfix">
          <li class="retweet">
            <a title="转发" href="#;"><i class="icon-reply"></i></a>
          </li>
        </ul>
        {% end %}
      </div>
    </div>
  </li>
</ul>
{% end %}
